package me.send.produce.client.controller;

import java.util.Map;

import me.send.business.service.bean.ReturnJsonBean;
import me.send.business.service.service.OpencityService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value="opencity")
public class OpencityController {

	@Autowired
	private OpencityService opencityService;
	
	// 获取手机界面 右边  热门城市的
	@RequestMapping(value="list/all")
	@ResponseBody
	public Map<String, Object> list_all(String devicenumber) {
		return opencityService.list_all(devicenumber);
	}
	
	/**
	 * 安卓端获取城市列表
	 * @param devicenumber
	 * @return
	 */
	@RequestMapping(value="cities")
	@ResponseBody
	public ReturnJsonBean citiesForAdnroid(String devicenumber){
		ReturnJsonBean rb = new ReturnJsonBean();
		try {
			Map<String, Object> map = opencityService.citiesForAndroid(devicenumber);
			rb.setDatas(map);
			rb.setCode(ReturnJsonBean.SUCCESS);
			rb.setMessage(ReturnJsonBean.SUCCESS_STR);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rb;
	}
	
	/**
	 * 根据传过来的经度纬度 获取城市的名称
	 * 
	 * 2015年6月9日09:48:48
	 * 
	 * 编辑人 ： 杨中仁
	 * 
	 */
	@RequestMapping(value="location/cityname")
	@ResponseBody
	public Map<String, Object> location_cityname(String devicenumber,String x,String y) {
		return opencityService.location_cityname(devicenumber, x, y);
	}
	
	
	@RequestMapping(value="opencity/save")
	@ResponseBody
	public int opencity_save(){
		return opencityService.opencity_save();
	}
	
}
